package br.com.wepa.webapps.orca.logica.modelo;

// Generated 12/01/2007 02:01:35 by Hibernate Tools 3.2.0.beta8

import java.util.HashSet;
import java.util.Set;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Funcao generated by hbm2java
 */
@Entity
@Table(name = "funcao", catalog = "Orca", uniqueConstraints = {})
public class Funcao implements java.io.Serializable {

	// Fields    

	/**
	 * 
	 */
	private static final long serialVersionUID = 8604465195981943668L;

	private FuncaoId id;

	private Modulo modulo;

	private String label;

	private String path;

	private String method;

	private Set<Menuitem> menuitems = new HashSet<Menuitem>(0);

	private Set<Credencial> credencials = new HashSet<Credencial>(0);

	// Constructors

	/** default constructor */
	public Funcao() {
	}

	/** minimal constructor */
	public Funcao(FuncaoId id, Modulo modulo, String label, String path) {
		this.id = id;
		this.modulo = modulo;
		this.label = label;
		this.path = path;
	}

	/** full constructor */
	public Funcao(FuncaoId id, Modulo modulo, String label, String path,
			String method, Set<Menuitem> menuitems, Set<Credencial> credencials) {
		this.id = id;
		this.modulo = modulo;
		this.label = label;
		this.path = path;
		this.method = method;
		this.menuitems = menuitems;
		this.credencials = credencials;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides( {
			@AttributeOverride(name = "idFuncao", column = @Column(name = "idFuncao", unique = false, nullable = false, insertable = true, updatable = true)),
			@AttributeOverride(name = "moduloIdModulo", column = @Column(name = "Modulo_idModulo", unique = false, nullable = false, insertable = true, updatable = true)) })
	public FuncaoId getId() {
		return this.id;
	}

	public void setId(FuncaoId id) {
		this.id = id;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "Modulo_idModulo", unique = false, nullable = false, insertable = false, updatable = false)
	public Modulo getModulo() {
		return this.modulo;
	}

	public void setModulo(Modulo modulo) {
		this.modulo = modulo;
	}

	@Column(name = "label", unique = false, nullable = false, insertable = true, updatable = true)
	public String getLabel() {
		return this.label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	@Column(name = "path", unique = false, nullable = false, insertable = true, updatable = true)
	public String getPath() {
		return this.path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Column(name = "method", unique = false, nullable = true, insertable = true, updatable = true)
	public String getMethod() {
		return this.method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "funcao")
	public Set<Menuitem> getMenuitems() {
		return this.menuitems;
	}

	public void setMenuitems(Set<Menuitem> menuitems) {
		this.menuitems = menuitems;
	}

	@ManyToMany(
        cascade={CascadeType.REMOVE, },
        mappedBy="funcaos",
        targetEntity=br.com.wepa.webapps.orca.logica.modelo.Credencial.class
    )
	public Set<Credencial> getCredencials() {
		return this.credencials;
	}

	public void setCredencials(Set<Credencial> credencials) {
		this.credencials = credencials;
	}

}
